package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.Commdity;
import com.example.demo.entity.Shop;
import com.example.demo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CommdityMapper extends BaseMapper<Commdity> {
    @Select("SELECT id,name,description,price,image,shopid,classification FROM commdity")
    List<Commdity> findAll();

    @Select("SELECT id,name,description,price,image,classification FROM commdity where shopid=#{shopid}")
    List<Commdity> findcommdity(int shopid);

    @Select("SELECT id,name,description,image,price FROM commdity where id=#{id}")
    List<Commdity>findby_id(int id);

    @Select("INSERT into shoppingcard(username,objectname,objectprice,image) values (#{username},#{objectname},#{objectprice},#{image})")
    Object addshoppingcart(String username,String objectname,double objectprice,String image);

    @Select("SELECT number,name,description,image,price FROM " +
            "shopcard1,commdity where shopcard1.commodityid=commdity.id and shopcard1.relaid=#{id}")
    List<Commdity>findBy_id(int relaid);

}


